<?php
class Models extends CActiveRecord {
	public static function model($className = __CLASS__) {
		parent::model ( $className );
	}
	public function tableName() {
		return '{{model}}';
	}
	public function rules() {
		
		return array (
			
			array (
				
				'name,tablename,category_template,list_template,show_template', 
				'required', 
				'message' => '不能为空' 
			) 
		);
	}
	public function relations() {
		
		return array ();
	}
	public function attributeLabels() {
		return array (
			
			"id" => "id", 
			"name" => "name", 
			"description" => "description", 
			"tablename" => "tablename", 
			"default_style" => "default_style", 
			"category_template" => "category_template", 
			"list_template" => "list_template", 
			"show_template" => "show_template", 
			"js_template" => "js_template", 
			"orders" => "orders", 
			"version" => "version" 
		);
	}
	public function getName() {
		$obj = $this->findAll ( array (
			
			"select" => "name,id" 
		) );
		$ret = CommonFunc::YiiobjectToArray ( $obj, "all" );
		foreach ( $ret as $v ) {
			$rows [$v ['id']] = $v ['name'];
		}
		return $rows;
	}
	public function getModels() {
		$obj = $this->findAll ();
		$ret = CommonFunc::YiiobjectToArray ( $obj, "all" );
		return $ret;
	}
	public function setModels($array) {
		$version = yii::app ()->session->get ( 'version' );
		$this->name = addslashes ( $array ['name'] );
		$this->description = addslashes ( $array ['description'] );
		$this->tablename = addslashes ( $array ['tablename'] );
		$this->category_template = addslashes ( $array ['category_template'] );
		$this->list_template = addslashes ( $array ['list_template'] );
		$this->show_template = addslashes ( $array ['show_template'] );
		if ($this->save () === NULL) {
			return FALSE;
		}
		return $this->id;
	}
}
?>